//
// Created by xili on 2024/7/31 9:23.
// Go big or go home.
//
#include <vector>

using namespace std;

class MyCircularQueue {
public:
    MyCircularQueue(int k) {
        queue.resize(k + 1);
        head = 0;
        tail = 0;
        size = k + 1;
    }

    bool enQueue(int value) {
        if (isFull()) {
            return false;
        }
        queue[tail] = value;
        tail = (tail + 1) % size;
        return true;
    }

    bool deQueue() {
        if (isEmpty()) {
            return false;
        }
        head = (head + 1) % size;
        return true;
    }

    int Front() {
        if (isEmpty()) {
            return -1;
        }
        return queue[head];
    }

    int Rear() {
        if (isEmpty()) {
            return -1;
        }
        return queue[(tail - 1 + size) % size];
    }

    bool isEmpty() {
        return head == tail;
    }

    bool isFull() {
        return (tail + 1) % size == head;
    }

private:
    int head;
    int tail;
    int size;
    vector<int> queue;
};

/**
 * Your MyCircularQueue object will be instantiated and called as such:
 * MyCircularQueue* obj = new MyCircularQueue(k);
 * bool param_1 = obj->enQueue(value);
 * bool param_2 = obj->deQueue();
 * int param_3 = obj->Front();
 * int param_4 = obj->Rear();
 * bool param_5 = obj->isEmpty();
 * bool param_6 = obj->isFull();
 */